Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update index.ts due to build errors on imported types #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hadbits
Copy link

@hadbits hadbits commented May 12, 2024

This implementation avoids the TypeScript error shared below when building a solution that has a dependency on groq-sdk with the tsconfig isolatedModules = true which is the recommended approach. I think what you have is using the "legacy" implementation of exporting types from namespaces where the types themselves were imported from other modules.

Look at this StackOverflow post:
https://stackoverflow.com/questions/30712638/typescript-export-imported-interface

Error I was getting:

./node_modules/.pnpm/[email protected]/node_modules/groq-sdk/src/index.ts:192:3 Type error: Cannot use 'export import' on a type or type-only namespace when 'isolatedModules' is enabled.

190 | export import fileFromPath = Uploads.fileFromPath;
191 |

192 | export import RequestOptions = Core.RequestOptions;
| ^
193 |
194 | export import Chat = API.Chat;
195 |
 ELIFECYCLE  Command failed with exit code 1.

This implementation avoids this TypeScript error when building a solution that has a dependency on groq-sdk. I think what you have is using the "legacy" implementation of exporting  types from namespaces where the types themselves were imported from other modules.

Look at this StackOverflow post:
https://stackoverflow.com/questions/30712638/typescript-export-imported-interface

Error I was getting:

./node_modules/.pnpm/[email protected]/node_modules/groq-sdk/src/index.ts:192:3
Type error: Cannot use 'export import' on a type or type-only namespace when 'isolatedModules' is enabled.

  190 |   export import fileFromPath = Uploads.fileFromPath;
  191 |
> 192 |   export import RequestOptions = Core.RequestOptions;
      |   ^
  193 |
  194 |   export import Chat = API.Chat;
  195 |
 ELIFECYCLE  Command failed with exit code 1.
@hadbits hadbits requested a review from gradenr as a code owner May 12, 2024 17:08
@rattrayalex
Copy link

How are you importing the library?

It should be import Groq from 'groq-sdk' not import Groq from 'groq-sdk/src'. The latter can cause issues like this.

If that's the case, we should close this PR, and I'm sorry for the footgun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants